package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Lesson;
import cn.wolfcode.crm.domain.Role;

import cn.wolfcode.crm.mapper.LessonMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ILessonService;
import cn.wolfcode.crm.util.PageResult;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;

@Service
public class LessonServiceImpl implements ILessonService {
    @Autowired
    private LessonMapper lessonMapper;

    public void saveOrUpdate(Lesson entity) {

    }

    public Lesson selectByPrimaryKey(Long id) {
        return lessonMapper.selectByPrimaryKey(id);
    }

    public List<Lesson> selectAll() {
        return lessonMapper.selectAll();
    }

    public PageResult quey4List(QueryObject qo) {
        Integer count = lessonMapper.query4Count(qo);
        if (count == 0){
            return PageResult.PAGERESULT_EMPTY;
        }
        List<Lesson> rows = (List<Lesson>) lessonMapper.query4List(qo);
        return new PageResult(count,rows);
    }


//    /**
//     * 用户获取获取课程模板
//     * @return
//     */
//    public Workbook getImportXlsMode() {
//        //创建xls
//        Workbook book = new HSSFWorkbook();
//        //创建工作簿
//        Sheet sheet = book.createSheet();
//        //设置第一行的标题
//        Row row = sheet.createRow(0);
//        row.createCell(0).setCellValue("用户名");
//        row.createCell(1).setCellValue("真实姓名");
//        row.createCell(2).setCellValue("密码");
//        row.createCell(3).setCellValue("联系方式");
//        row.createCell(4).setCellValue("邮箱");
//        /*row.createCell(5).setCellValue("所属部门");
//        row.createCell(6).setCellValue("入职日期");
//        row.createCell(7).setCellValue("状态");
//        row.createCell(8).setCellValue("管理员");
//        row.createCell(9).setCellValue("拥有的角色");*/
//        return book;
//    }
}
